package com.luania.todolist2.Adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.luania.todolist2.Model.TaskModel;
import com.luania.todolist2.R;


import java.util.ArrayList;
import java.util.List;

/**
 * Created by tyz1201 on 2016/4/2.
 */
public class TaskAdapter extends BaseAdapter {
    List<TaskModel> images = new ArrayList<>();
    Context context;
    String str;
    Boolean isNeedNotify;
    String notifyTime;

    public TaskAdapter(List<TaskModel> images, Context context) {
        this.images = images;
        this.context = context;
    }

    public int getCount() {
        return images.size();
    }


    @Override
    public Object getItem(int position) {
        return images.get(position);
    }


    @Override
    public long getItemId(int position) {
        return 0;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        //获取布局填充器
        LayoutInflater inflater = LayoutInflater.from(context);
        //使用布局填充器将布局填充到view中（解析xml）
        View view = inflater.inflate(R.layout.item_icon_task, parent, false);

        str = images.get(position).toString();
        String[] strs;
        strs = str.split("/");
        isNeedNotify = Boolean.parseBoolean(strs[2]);
        notifyTime = strs[0];

//        ImageView iv_icon_task = (ImageView) view.findViewById(R.id.iv_icon_task);
//        iv_icon_task.setImageResource(@mipmap.ic)

        TextView tv_icon_task = (TextView) view.findViewById(R.id.tv_icon_task);
        tv_icon_task.setText(images.get(position).getTaskName());

        return view;
    }

}

